<meta charset="utf-8" />
<button onclick="cal1()">-</button>
<input style="width:25px;"  id="n1" value="0" />
<button onclick="cal2()">+</button>

<script>
function cal1(){
    n1.value=parseInt(n1.value)-1;
    if(n1.value<=0){
        n1.value=0;
     }
  }

function cal2(){
    n1.value=parseInt(n1.value)+1;
    if(n1.value>10){
      alert("库存只有10件！");
        n1.value=10;
     }
  }
</script>